1. Technical Field
The present invention relates to an improved data processing system. In particular, the present invention relates to contributing resources of program annotations in a data processing system. Still more particularly, the present invention relates to extending annotation-based behavior to multiple annotation resources.
2. Description of Related Art
In modern development environments, programmers may use annotations declared in a source program to generate auxiliary artifacts or files that perform services. Many common artifacts, including home and remote interfaces and deployment descriptors of an enterprise Java™ Bean, can be automatically generated by an integrated development environment (IDE), a deployment tool, or a batch script using annotations.
In most development environments, an annotation is a comment declared in a source program that is preceded with a ‘@’ symbol. By using annotations, meta-data may be associated with program elements such as classes, methods, fields, parameters, local variables, and packages. For some programming languages, annotations are compiled and the metadata is stored in the class files. For other programming languages, annotations are interpreted and processed by an annotation processor. Later, the virtual machine or other programs can look for the metadata to determine how to interact with the program elements or change their behavior.
Currently, existing development tools that support annotation processing and artifacts generation, such as Ant, an open source product available from Apache Software Foundation, and XDoclet, an open source product available from the XDoclet team of the Apache Software Foundation, requires annotations to be self contained in a contributing resource from which the generated code is derived. This means that generally only one source file may be used for generation of one or more distinct compatible source files. However, there are a few exceptions, for example, using the XDoclet enterprise JavaBeans™ tag specification to support generation of enterprise Java™ beans, many source files contribute meta-data to the “ejb-jar.xml” deployment descriptor file. The J2EE enterprise JavaBeans™ specification is a product available from Sun Microsystems, Inc. The XDoclet enterprise JavaBeans™ tag specification specifies the ‘ejb’ annotation tagset that may be use to generate enterprise Java™ beans.
In this case, the output file is well known, static, and not arbitrarily or dynamically declared by the contributing files. Moreover, its name and structure are predefined and not extensible. In other words, one or more distinct source files are generated from the annotations in each annotated source file, and the meta-data from all annotated source files is combined into the deployment descriptor file.
In a common tag specification, an annotation in a source file may describe a generated file and subsequent annotations within the same source file may contribute behavior to this generated file. However, annotations from other source files may not be used to contribute behavior to this generated file.
Thus, current annotation-based models are limited to a single annotated source file for behavior contributions of a given generated file. This causes an explosion in the number of generated files, since a source file may contribute behavior to one or more generated files, but only one source file may be used to generate each generated file. This explosion leads to a complex application architecture devoid of logically partitioning or grouping of behavior in the generated files, driven by a higher number of generated files. All of which is undesirable by developers.
Therefore, it would be advantageous to have an improved method and apparatus that allows annotation-based behavior to be contributed from multiple annotated source files into a single set of generated related files, such that the behavior of the generated output can be more appropriately partitioned based on the business model, and potentially reducing the number of generated files, in order to provide a more flexible application architecture.